/******************************************/
/*********** Connection Wrapper ***********/
/******************************************/
/*
* FILE: connWrapper.h
* AUTHOR: Ram Subramanian and Nicolas Papin
* PROJECT: CS 3251 Project 2 - Professor Traynor
* DESCRIPTION: Shared connection functions.
* PURPOSE: Provides access to TCP functionality with wrappers to handle erroneous cases and perform some advanced functionality.
* Mostly this is to abstract the functionality that we want for GPStrac.
*/

#ifndef _CONN_WRAPPER_H
#define _CONN_WRAPPER_H

//
// FUNCTION DECLARATIONS
//
int serverInit(int port, int maxPending);
int handleConnection(int servSocket, void *(*handler)(void *));
int sendAmount(int destSock, const void *data, size_t amount);
int receiveAmount(int srcSock, void *outBuffer, size_t amount);

void dieWithMessage(char *message);

void htonRequest(clntReq_t *request);
void htonResponse(servResp_t *response);
void htonGPS(gpsCoord_t *gps);
void ntohRequest(clntReq_t *request);
void ntohResponse(servResp_t *response);
void ntohGPS(gpsCoord_t *gps);

#endif
